import http from "@/http";
import { Goods, GoodsListParams } from "./GoodsModel";

// 新增商品接口
// 对应后端 @RequestMapping("/api/goods")
export const addGoodsApi = (param: Goods) => {
  return http.post("/api/goods", param);
};

// 查询商品列表接口
export const queryGoodsListApi = (param: GoodsListParams) => {
  return http.get("/api/goods/getList", param);
};

// 上架
export const onShelfGoodsApi = (goodsId: number) => {
  return http.post(`/api/goods/onShelf/${goodsId}`);
};

// 上架
export const offShelfGoodsApi = (goodsId: number) => {
  return http.post(`/api/goods/offShelf/${goodsId}`);
};

// 编辑商品接口
export const editGoodsApi = (param: Goods) => {
  return http.put("/api/goods", param);
};

// 删除商品接口
export const deleteGoodsApi = (goodsId: number) => {
  return http.delete(`/api/goods/${goodsId}`);
};